<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets" xmlns="http://www.w3.org/1999/xhtml" xmlns:a4j="http://richfaces.org/a4j" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:st="http://www.whatisjee.com/ssf/tags" xmlns:rich="http://richfaces.org/rich" xmlns:s="http://jboss.com/products/seam/taglib" xmlns:sf="http://www.whatisjee.com/ssf/functions" template="/common/template/#{param['cb'] eq null ? 'header-content' : 'popup'}.xhtml">
	<ui:param name="title" value="#{messages['user.query']}"/>
	<ui:define name="content">
		<s:validateAll>
			<h:panelGrid columns="4" styleClass="form" columnClasses="label,input,label,input">
				<st:label for="itName" value="#{messages['user.name']}" />
				<s:decorate>
					<h:inputText id="itName" value="#{usersAct.criteria.name}" styleClass="inputtext width50" style="text-transform: uppercase" />
				</s:decorate>
				<st:label for="itFirstName" value="#{messages['user.firstName']}" />
				<s:decorate>
					<h:inputText id="itFirstName" value="#{usersAct.criteria.firstName}" styleClass="inputtext width50" />
				</s:decorate>
				<st:label for="itLastName" value="#{messages['user.lastName']}" />
				<s:decorate>
					<h:inputText id="itLastName" value="#{usersAct.criteria.lastName}" styleClass="inputtext width50" />
				</s:decorate>
			</h:panelGrid>
		</s:validateAll>
		<div class="buttons">
			<h:commandButton action="#{usersAct.find}" value="#{messages['cmm.find']}" styleClass="button" />
			<input type="button" value="#{messages['cmm.cancel']}" class="button cancel" onclick="Ssf.cancel()" />
		</div>	
		<rich:dataTable id="dtUsers" value="#{usersAct.data}" var="_user" rows="#{usersAct.data.page.rows}" styleClass="list">
			<rich:column sortBy="#{name}" styleClass="align-l" headerClass="align-l" selfSorted="true" sortOrder="ASCENDING">
				<f:facet name="header">
					<h:outputText value="#{messages['user.name']}"/>
				</f:facet>
				<h:outputText value="#{_user.name}" />
			</rich:column>
			<rich:column sortBy="#{firstName}" styleClass="align-l" headerClass="align-l">
				<f:facet name="header">
					<h:outputText value="#{messages['user.firstName']}"/>
				</f:facet>
				<h:outputText value="#{_user.firstName}" />
			</rich:column>
			<rich:column sortBy="#{lastName}" styleClass="align-l" headerClass="align-l">
				<f:facet name="header">
					<h:outputText value="#{messages['user.lastName']}"/>
				</f:facet>
				<h:outputText value="#{_user.lastName}" />
			</rich:column>
			<rich:column styleClass="align-l" headerClass="align-l">
				<f:facet name="header">
					<h:outputText value="#{messages['user.roles']}"/>
				</f:facet>
				<h:outputText value="#{sf:formatRoles(_user.roles)}" />
			</rich:column>
			<rich:column sortBy="#{enabled}" styleClass="align-c" headerClass="align-c">
				<f:facet name="header">
					<h:outputText value="#{messages['user.enabled']}"/>
				</f:facet>
				<h:outputText value="#{_user.enabled ? messages['cmm.yes'] : messages['cmm.no']}" />
			</rich:column>
			<rich:column sortBy="#{createdBy}" styleClass="align-l" headerClass="align-l">
				<f:facet name="header">
					<h:outputText value="#{messages['cmm.createdBy']}"/>
				</f:facet>
				<h:outputText value="#{_user.createdBy}" />
			</rich:column>
			<rich:column sortBy="#{createdAt}" styleClass="align-c" headerClass="align-c">
				<f:facet name="header">
					<h:outputText value="#{messages['cmm.createdAt']}"/>
				</f:facet>
				<h:outputText value="#{_user.createdAt}">
					<s:convertDateTime pattern="#{messages['cmm.shortDateTime']}" />
				</h:outputText>
			</rich:column>
			<rich:column sortBy="#{modifiedBy}" styleClass="align-l" headerClass="align-l">
				<f:facet name="header">
					<h:outputText value="#{messages['cmm.modifiedBy']}"/>
				</f:facet>
				<h:outputText value="#{_user.modifiedBy}" />
			</rich:column>
			<rich:column sortBy="#{modifiedAt}" styleClass="align-c" headerClass="align-c">
				<f:facet name="header">
					<h:outputText value="#{messages['cmm.modifiedAt']}"/>
				</f:facet>
				<h:outputText value="#{_user.modifiedAt}">
					<s:convertDateTime pattern="#{messages['cmm.shortDateTime']}" />
				</h:outputText>
			</rich:column>
			<rich:column styleClass="align-c" headerClass="align-c">
				<f:facet name="header">
					<h:outputText value="#{messages['cmm.operation']}"/>
				</f:facet>
				<s:link view="/admin/user.xhtml" styleClass="icon">
					<h:graphicImage value="/common/image/edit.png" alt="#{messages['cmm.edit']}" title="#{messages['cmm.edit']}" />
					<f:param name="id" value="#{_user.id}"/>
					<f:param name="pid" value="#{param['pid']}"/>
				</s:link>
				<h:commandLink action="#{usersAct.toggleStatus}" styleClass="icon">
					<h:graphicImage value="/common/image/disable.gif" alt="#{messages['user.disable']}" title="#{messages['user.disable']}" rendered="#{_user.enabled}" />
					<h:graphicImage value="/common/image/enable.png" alt="#{messages['user.enable']}" title="#{messages['user.enable']}" rendered="#{not _user.enabled}" />
				</h:commandLink>
			</rich:column>
		</rich:dataTable>
		<rich:datascroller for="dtUsers" />
	</ui:define>
</ui:composition>